<template>
  <max-dialog
    class="inner-editor-dialog"
    width="90%"
    top="5vh"
    :visible="visible"
    :before-close="handleClose"
  >
    <div slot="title" class="dialog-title">
      <el-divider content-position="left">{{ title }}</el-divider>
      <div class="description">{{ description }}</div>
      <el-divider></el-divider>
    </div>
    <mini-simulation-process
      :initGraphData="initGraphData"
      @save="handleSave"
    ></mini-simulation-process>
  </max-dialog>
</template>

<script>
import MiniSimulationProcess from "../../../../components/mini-simulation-process/index.vue";
import MaxDialog from "../../../../components/max-dialog/index.vue";

export default {
  name: "inner-func-editor",
  components: {
    MiniSimulationProcess,
    MaxDialog,
  },
  props: {
    visible: {
      type: Boolean,
      default: false,
    },
    node: {
      type: Object,
    },
  },
  data() {
    return {
      title: "inner-function",
      description: "在这里编写节点的内置函数...",
    };
  },
  computed: {
    initGraphData() {
      if (this.node.hasFunc) {
        return this.node.func;
      } else {
        return [];
      }
    },
  },
  methods: {
    handleClose() {
      this.$emit("close");
    },
    handleSave(data) {
      this.$emit("updateFunc", data);
    },
  },
};
</script>

<style lang="less">
.inner-editor-dialog {
  .max-dialog__body {
    padding: 10px 20px;
    height: 72vh;
  }
}
</style>
